#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;

int numSubseq(vector<int>& nums, int target) {
    sort(nums.begin(), nums.end());
    ll MOD = 1e9 + 7;
    ll ans = 0;
    int n = nums.size();
    int left = 0, right = n - 1;

    vector<ll> qsm(n, 1);
    for (int i = 1; i < n; ++i)
        qsm[i] = (qsm[i - 1] * 2) % MOD;

    while (left <= right) {
        if (nums[left] + nums[right] < target) {
            ans = (ans + qsm[right - left]) % MOD;
            ++left;
        }
        else
            --right;
    }
    return ans;
}

int main() {
    vector<int> nums = {3,5,6,7};
    cout << numSubseq(nums, 9);

}